Add a staking lock extension function allowing stakers to extend their lock period before it expires - #823
Open
Godfrey-Delight wants to merge 13 commits into
Conversation
…r lock period before it expires
|
@Godfrey-Delight Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…roceeds assignment
Godfrey-Delight
force-pushed
the
feat/stake-extend-unlock-ledger
branch
from
September 1, 2026 06:54
c0cd2db to
4963f19
Compare
Member
❌ CI Failed —
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds stake_extend(key_id: BytesN<32>, additional_ledgers: u32), allowing a wallet with an active stake to push back its unlock_ledger and continue earning rewards without unstaking and re-staking. Introduces StakePosition storage keyed by wallet and BytesN<32> key ID, validates that the caller has an active stake on the given key (panicking with the new NoStakeFound error otherwise), enforces that the resulting unlock_ledger is no more than 180 days out from the current ledger (panicking with the new LockTooLong error otherwise), bumps the TTL on the staking_positions entry after a valid extension, and emits a stake_extended event carrying wallet, key ID, old unlock_ledger, and new unlock_ledger. Takes an explicit wallet argument rather than relying on an invoker lookup, since this Soroban SDK does not expose Env::invoker(). Changes are in lib.rs and events.rs.
Closes #800
Changes
StakePositionstorage.stake_extend(wallet, key_id, additional_ledgers).NoStakeFoundwhen no active stake exists.LockTooLongwhen the limit is exceeded.stake_extendedwith wallet, key ID, and old/new unlock ledgers.Testing
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspaceChecklist
NoStakeFound,LockTooLong, event emission, and TTL bump.StakingPositionkey is additive; no existing keys are modified.stake_extendedevent with stable topic and payload field ordering.